#include<stdio.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include <time.h>
#include <sched.h>
int main()
{
int cnt=5;
while(cnt--)
{
  printf("\n");
  int count=100;
  pid_t id=fork();
  if(id<0)
  {
   printf("创建子进程失败\n");
   return -1; 
  }
  else if(id == 0)
  {
   //子进程执行代码区
   int* ptr=&count;
  *ptr=200;
   printf("I am child pid:%d,ppid:%d,count:%d,count的地址:%p\n",getpid(),getppid(),*ptr,ptr);
   exit(0);
  }
  else 
  {
   wait(id);
   //printf("父进程执行区\n");
   printf("I am father  pid:%d,ppid:%d,count:%d,count的地址:%p\n",getpid(),getppid(),count,&count);
  }
   
  printf("\n");
}
  return 0;
}
